package com.example.myapplication.navigation.fragment_recover;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.navigation.Navigation;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.myapplication.R;
import com.example.myapplication.databinding.FragmentProductDetailBinding;
import com.example.myapplication.databinding.viewmodel.UserViewModel;
import com.example.myapplication.navigation.fragment.BaseLifeFragment;
import com.example.myapplication.utils.NameCreator;

/**
 * A simple {@link Fragment} subclass.
 * create an instance of this fragment.
 */
public class ProductDetailFragmentLife extends BaseLifeFragment {
    FragmentProductDetailBinding binding;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        binding=FragmentProductDetailBinding.inflate(getLayoutInflater());
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        super.onCreateView(inflater,container,savedInstanceState);


        return binding.getRoot();
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        UserViewModel userViewModel= new ViewModelProvider(Navigation.findNavController(getView()).getViewModelStoreOwner(R.id.revover_graph)).get(UserViewModel.class);
        initEvent();
    }

    private void initEvent() {
        binding.btnGoProductDetails.setOnClickListener(Navigation.createNavigateOnClickListener(R.id.action_global_productListFragment_to_productDetailFragment));
        binding.btnGoProductDetailsSingleTop.setOnClickListener(Navigation.createNavigateOnClickListener(R.id.action_productListFragment_to_productDetailFragment_singleTop));

    }

    @Override
    public String initLogHead() {
        return NameCreator.getInstance().getName("************************ProductDetailFragment", hashCode());
    }

}
